﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ZackFlame.SimpleBrainFuck
{
    public static class EnumerableExtensions
    {
        public static IEnumerable<TResult> Zip<T1, T2, TResult>(
            this IEnumerable<T1> first, 
            IEnumerable<T2> second, 
            Func<T1, T2, TResult> zipper)
        {
            using (var ie1 = first.GetEnumerator())
            using (var ie2 = second.GetEnumerator())
            {
                while (ie1.MoveNext() && ie2.MoveNext())
                {
                    yield return zipper(ie1.Current, ie2.Current);
                }
            }
        }
    }
}
